#include <iostream>
using namespace std;

class Solution 
{
public:
    int getDecimalValue(ListNode* head) 
    {
        // 虽然题目明确告知我们head不为空, 但我们仍然需要判断
        if (NULL == head)
            return 0;
        else
        {
            ListNode* cur = head;
            int ret = 0;
            while (cur != NULL)
            {
                ret = ret * 2 + cur->val;
                cur = cur->next;
            }
            return ret;
        }
    }
};

